package com.taoz.rpc.core.registry;

import com.taoz.rpc.core.model.ServiceMetaInfo;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class RegistryServiceCache {
    private Map<String, List<ServiceMetaInfo>> cache = new ConcurrentHashMap<>();

    void cacheService(String serviceName, List<ServiceMetaInfo> serviceList) {
        cache.put(serviceName, serviceList);
    }

    void removeService(String serviceName) {
        cache.remove(serviceName);
    }

    List<ServiceMetaInfo> getService(String serviceName) {
        return cache.get(serviceName);
    }

    void clearCache() {
        cache = new ConcurrentHashMap<>();
    }

}
